




package com.yinhai.ta404.core.autoconfigure;

import java.util.HashMap;
import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(
        prefix = "ta404.validation"
)
public class TaCustomRegexProperties {
    private Map<String, TaRegexMessageProperties> customRegex;

    public TaCustomRegexProperties() {
        HashMap<String, TaRegexMessageProperties> hashMap = new HashMap(8);
        hashMap.put("email", new TaRegexMessageProperties("^[a-z0-9]+@[a-z0-9]+\\.[a-z0-9]+$", "邮箱格式不正确"));
        hashMap.put("emailOrEmpty", new TaRegexMessageProperties("^[a-z0-9]+@[a-z0-9]+\\.[a-z0-9]+$|\\s*", "邮箱格式不正确"));
        hashMap.put("cellphone", new TaRegexMessageProperties("^[0-9]{11}$", "电话号码格式不正确"));
        hashMap.put("cellphoneOrEmpty", new TaRegexMessageProperties("^[0-9]{11}$|\\s*", "电话号码格式不正确"));
        this.customRegex = hashMap;
    }

    public Map<String, TaRegexMessageProperties> getCustomRegex() {
        return this.customRegex;
    }

    public void setCustomRegex(final Map<String, TaRegexMessageProperties> customRegex) {
        this.customRegex = customRegex;
    }
}
